<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="UTF-8"%>
<table width="600" border="1" align="center" cellpadding="1" cellspacing="1">
            <tr>
            <td align="center" valign="middle">用户名</td>
            <td align="center" valign="middle">密码</td>
            <td align="center" valign="middle">操作</td>
            </tr>
<%
  ResultSet rs=null;
  Connection con=null;
  try{
  Class.forName("com.mysql.jdbc.Driver");
  String url="jdbc:mysql://localhost:3306/test";
  String username="root";
  String password="root";
  con=DriverManager.getConnection(url, username, password);
  String sql="select * from users";
  Statement sm=con.createStatement();
  rs=sm.executeQuery(sql);
  
  while(rs.next()){
   %>
  <tr>
    
    <td align="center" valign="middle"><%=rs.getString("username") %></td>
    <td align="center" valign="middle"><%=rs.getString("password") %></td>
    <td align="center" valign="middle"><a href="shanchu.jsp?id=<%=rs.getInt("id")%>">删除</a>&nbsp;|&nbsp;<a href="chakan.jsp?id=<%=rs.getInt("id")%>">查看</a></td>
  </tr>
  <% }
  rs.close();sm.close();con.close();
  }catch(ClassNotFoundException e){e.printStackTrace();}catch(SQLException e){e.printStackTrace();}
  %>
</table>


 
